// 添加标注并显示信息窗口js

//创建地址解析器实例
function newCoord(jsonStr){
	//var myGeo = new BMap.Geocoder();
	//将地址解析结果显示在地图上
	var points = [];   
	$.each(jsonStr,function(_key){
		var obj = jsonStr[_key];
		var point = new BMap.Point(obj.lng,obj.lat);
		points.push(point);
	});
	var options = {  
        //size: 6,  
        shape: BMAP_POINT_SHAPE_WATERDROP  //水滴状，该类型无size和color属性
        //color: '#ED2D2D'  
    };  
	basestationPointCollection = new BMap.PointCollection(points, options);  // 初始化PointCollection  
    basestationPointCollection.addEventListener('click', function (e) {  
          var max="";//地址  
          var qi="";//地址  
          var dian="";//地址  
          var jie="";//地址  
          //关于自定义信息 修改json [[经度,维度,1,名称,地址,电话]]  
          //循环查出值  
          for (var i = 0; i < jsonStr.length; i++) {  
              points.push(new BMap.Point(jsonStr[i].lng,jsonStr[i].lat));  
              if(jsonStr[i].lng==e.point.lng&&jsonStr[i].lat==e.point.lat){//经度==点击的,维度  
            	  max=jsonStr[i].max;  
            	  qi=jsonStr[i].qi;  
            	  dian=jsonStr[i].dian;  
            	  jie=jsonStr[i].jie;  
                  break;  
              }  
          }  
          var point = new BMap.Point(e.point.lng, e.point.lat);  
          var opts = {  
              width: 300, // 信息窗口宽度  
              height: 150, // 信息窗口高度  
              //title:"", // 信息窗口标题  
              enableMessage: false,//设置允许信息窗发送短息  
          }  
          var content = "<div class='modal' style='height: 150px;width:300px'>" +
		  "<div><font style= 'color:red'>"+max+"</font></div>" +
          "<div style='padding: 5px;'><img src='/dhjdglxt/ui/layui/images/dashboard/icon2.png' style='margin-right: 10px;width: 30px;'></img>煤改气(/户)：<font style= 'size:10'>"+qi+"</font></div>"+
          "<div style='padding: 5px;'><img src='/dhjdglxt/ui/layui/images/dashboard/icon3.png' style='margin-right: 10px;width: 30px;'></img>煤改电(/户)：<font style= 'size:10'>"+dian+"</font></div>"+
          "<div style='padding: 5px;'><img src='/dhjdglxt/ui/layui/images/dashboard/icon4.png' style='margin-right: 10px;width: 30px;'></img>煤改洁净煤(/户)：<font style= 'size:10'>"+jie+"</font></div>";
          var infowindow = new BMap.InfoWindow(content,opts);  
          map.openInfoWindow(infowindow, point);  
      });  
    map.addOverlay(basestationPointCollection);  // 添加Overlay  
	
}




//创建地址解析器实例
function newCoord2(jsonStr){
	//var myGeo = new BMap.Geocoder();
	//将地址解析结果显示在地图上
	var points = []; 
	$.each(jsonStr,function(_key){
		var obj = jsonStr[_key];
		var point = new BMap.Point(obj.lng,obj.lat);
		points.push(point);
	});
	var options = {  
        //size: 6,  
        shape: BMAP_POINT_SHAPE_WATERDROP  //水滴状，该类型无size和color属性
        //color: '#ED2D2D'  
    };  
	basestationPointCollection = new BMap.PointCollection(points, options);  // 初始化PointCollection  
    basestationPointCollection.addEventListener('click', function (e) {  
          var address="";//地址  
          var name="";//地址  
          var sales="";//地址  
          //关于自定义信息 修改json [[经度,维度,1,名称,地址,电话]]  
          //循环查出值  
          for (var i = 0; i < jsonStr.length; i++) {  
              points.push(new BMap.Point(jsonStr[i].lng,jsonStr[i].lat));  
              if(jsonStr[i].lng==e.point.lng&&jsonStr[i].lat==e.point.lat){//经度==点击的,维度  
            	  address=jsonStr[i].address;  
            	  name=jsonStr[i].name;  
            	  sales=jsonStr[i].sales;  
                  break;  
              }  
          }  
          var point = new BMap.Point(e.point.lng, e.point.lat);  
          var opts = {  
              width: 400, // 信息窗口宽度  
              height: 70, // 信息窗口高度  
              //title:"", // 信息窗口标题  
              enableMessage: false,//设置允许信息窗发送短息  
          }  
          var content = "<div class='modal' style='height: 70px;width:400px'>" +
						  "<div>地址：<font style= 'color:red'>"+address+"</font></div>" +
						  "<div>配送中心名称：<font style= 'color:black'>"+name+"</font></div>"+
				          "<div>月销售量（吨）：<font style= 'size:10'>"+sales+"</font></div>";
          var infowindow = new BMap.InfoWindow(content,opts);  
          map2.openInfoWindow(infowindow, point);  
      });  
    map2.addOverlay(basestationPointCollection);  // 添加Overlay  
	
}


